package cn.com.connext.scrm.repository.master;

import cn.com.connext.scrm.domain.master.Product;
import cn.com.connext.scrm.domain.master.SupportThirdInterface;
import cn.com.connext.scrm.service.dto.JsonResult;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.time.ZonedDateTime;
import java.util.Date;
import java.util.List;

@Repository
public interface SupportThirdInterfaceRepository extends JpaRepository<SupportThirdInterface, String>, JpaSpecificationExecutor {
      @Query(value = "select count(1) FROM support_third_interface where unique_code= :uniqueCode ",nativeQuery = true)
      Integer findIsExist(@Param("uniqueCode") String uniqueCode);

    SupportThirdInterface findByUniqueCodeAndSkuId(@Param("uniqueCode")String uniqueCode, @Param("skuId")String skuId);

    SupportThirdInterface findByUniqueCode(@Param("uniqueCode")String uniqueCode);
    @Query(value = "select * FROM support_third_interface where unique_code in :uniqueCodes ",nativeQuery = true)
    List<SupportThirdInterface> findByCondition(@Param("uniqueCodes")List<String> uniqueCodes);
    @Query(value = "select count(*) FROM support_third_interface where create_time = :createTime ",nativeQuery = true)
    Integer findCountByCreateTime(@Param("createTime") String createTime);
//    @Transactional
//    @Modifying
//    @Query(value = "update product pr set pr.stock =:stock ,pr.update_time =now() where pr.stock =:stockOld and  id =:id ", nativeQuery = true)
//    Integer updateStock(@Param("stock") Integer stock, @Param("stockOld") Integer stockOld, @Param("id") String id);
//
//    Product findByCouponId(String id);
//
//    @Query(value = "select pr.* from product pr  where pr.coupon_id =:couponId and  pr.is_delete = 0  ", nativeQuery = true)
//    List<Product> findAllByCouponId(@Param("couponId") String couponId);
}
